home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Generic Fax2&ARA Direct < prev    next >
Text File  |  1993-12-11  |  6KB  |  271 lines

  1. ! Version 2.1
  2. !
  3. !$ Requires: Class 2 fax modem.
  4.  
  5. !$ Supports: fax and ARA software in the server mode.
  6.  
  7. !$ Use:   Class 2 for Fax, ARA/LineShare for ARA.
  8.  
  9. !$ Read:  your modem manual to modify the "AT" strings.
  10.  
  11. !$ See:   the Generic Scripts Guide for details.
  12.  
  13.  
  14. ^2 Speaker On:          = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  15. ^3 Speaker Volume:         = Enum("Low"="1","Medium"="2","High"="3") "2"
  16. ^4 Answer On:           = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  17. ^5 Fax Identifier:      = Text "Stalker_GmbH"
  18. ^6 AT for Direct mode:  = Text ""
  19. ^7 AT for No Handshake: = Text ""
  20. ^8 AT for SW Handshake: = Text ""
  21. ! ------------------------------------------
  22. ! Resetting the modem:
  23. ! ------------------------------------------
  24. @Hangup
  25.   SetTries 2
  26.   Flush
  27.   HsReset 0,0,17,19,0,0
  28. !
  29. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  30. ! to enter the command mode
  31. !
  32. @Label 1
  33.   matchclr
  34.   matchstr 1 2 "OK\r\n"
  35.   write "ATH0&F\r"
  36.   matchread 20
  37.   Write "+++"
  38.   DtrClear
  39.   LBreak
  40.   DtrSet
  41. !
  42.   DecTries
  43.   IfTries 0 1
  44. !
  45. ! OSErr -6019 "Modem error - the modem is not responding"
  46. !
  47.   exit -6019
  48. @Label 2
  49.   write "AT+FCLASS=0\r"
  50.   Jsr 100
  51.   write "AT+FAA=0\r"
  52.   Jsr 100
  53.   exit 0
  54.  
  55. ! ------------------------------------------
  56. !    Receiving incoming calls
  57. ! ------------------------------------------
  58. @ANSWER
  59. SetVar A ""
  60. IfStr A 50 "^6^7^8"
  61. @Label 10
  62. !
  63. ! Set the modem preferred speed first
  64. !
  65.   SerReset 19200,0,8,1
  66.   Jsr 80
  67. !
  68. ! Set the common options
  69.   Jsr 70
  70. !
  71. ! Set the communication options:
  72. ! • Normal connection (for ARA), report DCE speed
  73. ! • HW flow control       (for ARA, Fax should not use a handshake on receiving)
  74.   Write "AT^7^6\r"
  75.   Jsr 100
  76. !
  77. ! Set Fax parameters: LID, DCC,BOR
  78. !
  79.   Write "AT+FCLASS=2\r"
  80.   Jsr 100
  81.   Write "AT+FLID=\"^5\"\r"
  82.   Jsr 100
  83.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  84.   Jsr 100
  85.   Write "AT+FBOR=1\r"
  86.   Jsr 100
  87. !
  88. ! Allow modem to receive fax messages
  89. !
  90.   Write "AT+FCR=1\r"
  91.   Jsr 100
  92. !
  93. ! Tell the modem to determine the type of the incoming call
  94. ! Fetch the tube after N rings, where N has been set in the control panel (^4)
  95. !
  96.   Write "ATS0=^4+FAA=1\r"
  97.   Jsr 100
  98. !
  99. ! Everything is ready - let's sit and wait for a call
  100. ! We'll wait for 2 minutes, then reinitiate the modem
  101. !
  102.   Note "Waiting for a fax or ARA call…"
  103. @Label 15
  104.   MatchClr
  105.   matchstr 1 16 "RING\r\n"
  106.   matchstr 3 20 "\r\nCONNECT "
  107.   matchstr 5 30 "\r\n+FCON"
  108.   matchstr 6 10 "\r\nNO "
  109.   matchstr 7 10 "\r\nBUSY"
  110.   Matchread 1200
  111.   jump 10
  112. @Label 16
  113.   Note "Ring…"
  114.   jump 15
  115. !
  116. ! Data connection has been established (we read "CONNECT")
  117. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  118. ! if it was an incoming call, put the "RING" before the "CONNECT"
  119. !
  120. @Label 20
  121.   QueueInput "\r\CONNECT "
  122.   ifOriginate 21
  123.   QueueInput "\r\nRING\r\n"
  124. @Label 21
  125.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  126. !
  127. ! Fax connection has been established (we read "+FCON")
  128. ! Put the +FCON back to the buffer,
  129. ! if it was an incoming call, put the "RING" before the "+FCON"
  130. ! Attach the "Fax" subPort
  131. !
  132. @Label 30
  133.   QueueInput "\r\n+FCON"
  134.   ifOriginate 31
  135.   QueueInput "\r\nRING\r\n"
  136. @Label 31
  137.   Attach "Fax" (DTR,Reset,Escape,IdleLimit=30)
  138.  
  139. @Label 50
  140.   Note "Suspended"
  141.   Say "Press the Option button to enter the AT-strings for your modem!"
  142.   Pause 1200
  143.   Jump 50
  144. ! ------------------------------------------
  145. ! Originating a call through the "ARA" subport
  146. ! ------------------------------------------
  147. @ORIGINATE "ARA"
  148.   SerReset 19200,0,8,1
  149.   Jsr 80
  150. !
  151. ! Set the common options
  152. !
  153.   Jsr 70
  154. !
  155. ! Set the Data mode:
  156. ! • Normal connection (no compression, correction - for ARA), report DCE rate
  157. ! • HW Handshake
  158. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  159. !
  160.   Write "AT^7^6S7=90\r"
  161.   Jsr 100
  162. !
  163. ! Prepare to receive all error result codes, dial the number
  164. !
  165.   Jsr 90
  166.   MatchStr 1 20 "\r\nCONNECT "
  167.   MatchRead 900
  168.   Write "\r"
  169.   Exit -6019
  170.  
  171. ! ------------------------------------------
  172. ! Originating a call through the "Fax" subPort
  173. ! ------------------------------------------
  174. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  175. !
  176. ! Set the "Fax" speed
  177. !
  178.   SerReset 19200,0,8,1
  179.   Jsr 80
  180. !
  181. ! Set the common options
  182. !
  183.   Jsr 70
  184. !
  185. ! Set the Fax mode
  186. ! • Xon/Xoff handshake
  187. ! • DSR always on
  188. !
  189.   Write "AT&S0^8+FCLASS=2\r"
  190.   Jsr 100
  191. !
  192. ! Now emit all commands that the application has sent to that port,
  193. !
  194.   Jsr 60
  195. !
  196. ! Prepare to receive all error result codes, dial the number
  197. !
  198.   Jsr 90
  199.   MatchStr 1 30 "\r\n+FCON"
  200.   MatchRead 900
  201.   Write "\r"
  202.   Exit -6019
  203. !
  204. ! This section emits all modem commands sent from the client application
  205. ! For each set of commands the "OK" answer is awaited
  206. !
  207. @Label 60
  208.   EmitStart
  209. @Label 61
  210.   EmitCommand 62
  211.   Jsr 100
  212.   Jump 61
  213. @Label 62
  214.   return
  215. !
  216. ! This section initiates the modem before ANSWER and ORIGINATEs:
  217. ! extended responses + speaker control +
  218. ! command mode on Dtr drop + DCD valid
  219. ! Verbal responses mode, no echo 
  220. !
  221. @Label 70
  222.   Write "ATX4M^2L^3&D2&C1V1E0\r"
  223.   Jsr 100
  224.   return 
  225.  
  226. !
  227. ! This section syncronize the modem after the serial port speed switching
  228. !
  229. @Label 80
  230.   ChrDelay 1
  231.   Write "AT\r"
  232.   ChrDelay 0
  233.   Jsr 100
  234.   return
  235. !
  236. ! Prepare to receive error result codes, send the dialing command and
  237. ! set the user's handshake mode
  238. !
  239. @Label 90
  240.   MatchClr
  241.   MatchStr 2 91 "NO DIALTONE\r\n"
  242.   MatchStr 3 92 "BUSY\r\n"
  243.   MatchStr 4 93 "NO CARRIER\r\n"
  244.   MatchStr 5 94 "NO ANSWER\r\n"
  245.   Write "ATD^1\r"
  246.   HsReset *
  247.   return
  248. @Label 91
  249.   exit -6020
  250. @Label 92
  251.   exit -6022
  252. @Label 93
  253.   exit -6021
  254. @Label 94
  255.   exit -6023
  256. !
  257. ! Processing the AT command:
  258. ! OK -> proceed
  259. ! ERROR or TimeOut ->exit -6019
  260. ! It can be called AFTER the "Write" command, since LineShare buffers input
  261. !
  262. @Label 100
  263.   MatchClr
  264.   MatchStr 1 102 "\r\nOK\r\n"
  265.   MatchStr 2 101 "\r\nERROR\r\n"
  266.   MatchRead 20
  267. @Label 101
  268.   Exit -6019
  269. @Label 102
  270.   return
  271.